package com.gitee.streamrabbitmqprovider.message.impl;

import com.gitee.streamrabbitmqprovider.message.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;


/**
 * @ClassName MessageServiceImpl
 * @Description TODO
 * @Author xiongchao
 * @Date 2021/1/4 15:38
 **/
//定义消息的推送通道
@EnableBinding(Source.class)
public class MessageServiceImpl implements IMessageService {

    @Resource
    private MessageChannel output;

    @Override
    public String send() {
        String serial  = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(serial).build());
        System.out.println(serial);
        return null;
    }
}
